class Playground {
    constructor(ctx) {
        this.ctx = ctx
        this.width = ctx.width
        this.height = ctx.height

        this.gameMap = new GameMap(this)
        this.players = []
        this.start()
    }

    start() {
        this.listen_and_serve()
    }

    listen_and_serve() {
        let outer = this
        window.addEventListener('mousedown', function (e) {
            let p = {
                x: e.clientX,
                y: e.clientY
            }
            let v = {
                x: (Math.random() - 0.5) * outer.width / 10,
                y: (Math.random() - 0.5) * outer.width / 10,
            }

            let player = new Player(outer, outer.players.length, p, v, outer.height * 0.2, outer.get_random_bg())
            outer.players.push(player)
        })
    }

    get_random_bg() {
        return "../asset/fu1.png"
    }
}